import { Router, Route, Switch } from 'react-router-dom'
import React, { Suspense } from 'react'
// import Login from './pages/Login/index'
// import Layout from './pages/Layout/index'
import AuthRoute from 'components/AuthRoute/index'
import history from 'utils/history'
const Login = React.lazy(() => import('pages/Login'))
const Layout = React.lazy(() => import('pages/Layout'))
function App() {
  return (
    <Router history={history}>
      <div className="App"></div>
      <Suspense fallback={<div>loading...</div>}>
        <Switch>
          {/* <Route
          path="/home"
          render={(props) => {
            if (isToken()) {
              return <Layout {...props}></Layout>
            } else {
              return <Redirect to="/login"></Redirect>
            }
          }}
        ></Route> */}
          <AuthRoute path="/home" component={Layout}></AuthRoute>
          <Route path="/login" component={Login}></Route>
        </Switch>
      </Suspense>
    </Router>
  )
}
export default App
